home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: lyra.csx.cam.ac.uk!warwick!bsmail!talisker!nathan
- From: nathan@pact.srf.ac.uk (Nathan Sidwell)
- Subject: Re: Can main() function be called?
- Message-ID: <DMAtsL.GwE@uns.bris.ac.uk>
- Sender: usenet@uns.bris.ac.uk (Usenet news owner)
- Nntp-Posting-Host: talisker.pact.srf.ac.uk
- Organization: Inmos
- X-Newsreader: TIN [version 1.2 PL2]
- References: <4f3hgv$ml8@columba.udac.uu.se>
- Date: Mon, 5 Feb 1996 10:43:32 GMT
-
- Fredrik Raadesand (m92fra@sabik.tdb.uu.se) wrote:
- : > I think that it cannot be done, I see no reasonalbe way how main()
- : > could be called more than once.
- Yes, there's nothing especially magic about main. The special thing is
- that somewhere in the c startup there's a call to it. It's the only
- user defined function which the C startup calls without being
- told to by the user program.
-
- : I would say the simplest way to find out is to try it out ?
- : ...to post the question on the net is probably more difficult. ;)
-
- : Either it works or it doesn't, right ?
- This is a dangerous fallacy. Your particular implementation does
- not define the standard. In the abcense of knowledge of the standard,
- it is impossible to tell whether what happens, is because
- a)the standard said so
- b)the standard said it's implementation defined
- c)the standard said it's undefined.
- b & c are different. B requires an implementation to define what happens
- C means the implementation can do anything, and it can do different things
- each time.
-
- examples are (a, b & c are ints)
- a) a = 1;
- b) b = -5 / 2; /* result -2 or -3 */
- c) c = c++; /* undefined, modified twice between sequence points */
-
- nathan
-
- --
- Nathan Sidwell Holder of the Xmris home page
- Chameleon Architecture Group at SGS-Thomson, formerly Inmos
- http://www.pact.srf.ac.uk/~nathan/ Tel 0117 9707182
- nathan@inmos.co.uk or nathan@bristol.st.com or nathan@pact.srf.ac.uk
-